package com.gao.interceptordemo.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
import java.util.Map;

/*
 * @ConfigurationProperties:将配置文件中配置的每一个属性的值,映射到这个组件中,
 * 告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定
 */

/**
 * @author gaofeng
 * date 2021年09月25日 15:58
 */
@Component //注册Bean
@Validated //JSR303数据校验
@ConfigurationProperties(prefix = "student")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
//@PropertySource(value = "classpath:application.properties")
public class Student {
    /** SpEl表达式取出配置的值
     *
     * */
//    @Value(value = "${name}")
    private String name ;
//    @NotBlank
    private Integer age ;
//    @Max(15)
    private Boolean happy ;
//    @DateTimeFormat
    private Date birth ;
    private Map<String, Object> maps ;
    private List<Object> objects ;
    private Cat cat ;

}
